package com.mingdinggroup.app.util;

import android.app.Activity;

import com.umeng.socialize.UMShareListener;
import com.umeng.socialize.bean.SHARE_MEDIA;
import com.umeng.socialize.utils.Log;

import java.lang.ref.WeakReference;

/**
 * 作者：woodnaonly on 2017/4/19 11:11
 * 邮箱：497917264@qq.com
 * 内容：
 * 备注：
 */
public class CustomShareListener implements UMShareListener {

    private WeakReference<Activity> mActivity;

    public CustomShareListener(Activity activity) {
        mActivity = new WeakReference(activity);
    }

    @Override
    public void onStart(SHARE_MEDIA platform) {

    }

    @Override
    public void onResult(SHARE_MEDIA platform) {

        if (platform.name().equals("WEIXIN_FAVORITE")) {

        } else {
            if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
                    && platform != SHARE_MEDIA.EMAIL && platform != SHARE_MEDIA.FLICKR
                    && platform != SHARE_MEDIA.FOURSQUARE && platform != SHARE_MEDIA.TUMBLR
                    && platform != SHARE_MEDIA.POCKET && platform != SHARE_MEDIA.PINTEREST

                    && platform != SHARE_MEDIA.INSTAGRAM && platform != SHARE_MEDIA.GOOGLEPLUS
                    && platform != SHARE_MEDIA.YNOTE && platform != SHARE_MEDIA.EVERNOTE) {

                ToastUtil.getInstance().showToast(" 分享成功啦");

            }

        }
    }

    @Override
    public void onError(SHARE_MEDIA platform, Throwable t) {
        if (platform != SHARE_MEDIA.MORE && platform != SHARE_MEDIA.SMS
                && platform != SHARE_MEDIA.EMAIL && platform != SHARE_MEDIA.FLICKR
                && platform != SHARE_MEDIA.FOURSQUARE && platform != SHARE_MEDIA.TUMBLR
                && platform != SHARE_MEDIA.POCKET && platform != SHARE_MEDIA.PINTEREST

                && platform != SHARE_MEDIA.INSTAGRAM && platform != SHARE_MEDIA.GOOGLEPLUS
                && platform != SHARE_MEDIA.YNOTE && platform != SHARE_MEDIA.EVERNOTE) {


            ToastUtil.getInstance().showToast( " 分享失败啦");
            if (t != null) {
                Log.d("throw", "throw:" + t.getMessage());
            }
        }

    }

    @Override
    public void onCancel(SHARE_MEDIA platform) {
        ToastUtil.getInstance().showToast(" 分享取消了");

    }
}